{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 12)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "from scipy.ndimage import zoom\n",
    "\n",
    "a = np.array([[0, 0, 0, 5, 6],\n",
    "              [0, 0, 0, 5, 6],\n",
    "              [4, 4, 5, 6, 8]])\n",
    "\n",
    "b = zoom(a, [10/3, 12/5]) # 实现对矩阵维数的缩放\n",
    "\n",
    "b.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0,  0,  0,  0,  0,  0,  1,  3,  5,  6,  6,  6],\n",
       "       [ 0,  0,  0,  0, -1, -1,  1,  3,  5,  6,  6,  6],\n",
       "       [ 0,  0,  0,  0, -1, -1,  0,  2,  5,  6,  6,  6],\n",
       "       [ 0,  0,  0, -1, -1, -1,  0,  2,  4,  6,  6,  6],\n",
       "       [ 0,  0,  0,  0, -1, -1,  0,  2,  5,  6,  6,  6],\n",
       "       [ 0,  0,  0,  0,  0,  0,  1,  3,  5,  6,  6,  6],\n",
       "       [ 1,  2,  2,  1,  1,  2,  2,  4,  5,  6,  7,  7],\n",
       "       [ 3,  3,  3,  3,  3,  3,  4,  4,  5,  6,  7,  7],\n",
       "       [ 4,  4,  4,  4,  4,  4,  5,  5,  6,  7,  7,  8],\n",
       "       [ 4,  4,  4,  4,  4,  5,  5,  5,  6,  7,  8,  8]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0, 0, 0, 0, 1, 3, 5, 5, 6, 6],\n",
       "       [0, 0, 0, 0, 0, 0, 1, 3, 5, 5, 6, 6],\n",
       "       [0, 0, 0, 0, 0, 0, 1, 3, 5, 5, 6, 6],\n",
       "       [0, 0, 0, 0, 0, 0, 1, 3, 5, 5, 6, 6],\n",
       "       [0, 0, 0, 0, 0, 0, 1, 3, 5, 5, 6, 6],\n",
       "       [0, 0, 0, 0, 0, 1, 1, 3, 5, 5, 6, 6],\n",
       "       [1, 1, 1, 1, 1, 2, 2, 4, 5, 6, 6, 7],\n",
       "       [2, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7, 7],\n",
       "       [3, 3, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8],\n",
       "       [4, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = zoom(a, [10/3, 12/5], order=1) # 为zoom()函数指定order参数值\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
